package ar.com.ctrln.persistence.dao.ticket;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import ar.com.ctrln.persistence.dao.AbstractHibernateDao;
import ar.com.ctrln.persistence.model.ticket.TipoTicket;

@Repository("tipoTicketDao")
public class HibernateTipoTicketDao extends AbstractHibernateDao<TipoTicket> implements TipoTicketDao {

		
	@Override
	public TipoTicket findTipoTicketById(long id) {
		Query q = getSession().createQuery("from TipoTicket t where t.id = ?");
		q.setParameter(0, id);
		return (TipoTicket) q.uniqueResult();
	}

	@Override
	@Transactional(readOnly = true)
	public TipoTicket getTipoTicket(String tipo) {
		Query q = getSession().createQuery("from TipoTicket t where t.nombre = ?");
		q.setParameter(0, tipo);
		return (TipoTicket) q.uniqueResult();
	}

}
